<!-- directive:title $api 完整使用说明 -->
<!-- directive:breadcrumb 重要服务 -->
<div class="panel-body">
    <p>1 mockjs负责模拟后台发送来的数据</p>
    <p>2 api负责收集信息 整理并规范成后台需要的参数 发送并接受返回值 整理取出有用内容</p>
    <p>3 业务逻辑部分负责声明js中好用的对象格式 好去好来</p>
    <p>======================</p>
    <p>4 目的是使脉络清晰 后端出问题/传参出问题/前端出问题 一目了然</p>
    <button type="button" class="btn btn-success" ng-click="f11()">$API.Drop.Customer</button>
    {{ data }}
    <script type="text/xian" ui-bs>
        if(param.url == '/api/customer/getlistMock'){
            var mock = { "code": 200, "msg":"", "data": [ {"id": 11, "name": "假数据1"}, ...} ] };
            return cb(mock);
        }
    </script>
    <script type="text/xian" ui-bs>
        $API.Drop.Customer = function(opt, params){
            var nosearch = opt.indexOf('nosearch') > -1
            var noall = opt.indexOf('noall') > -1
            var arr = noall ? [{id: 0, name:"全部用户"}] :[];
            return new Promise(function(resolve, reject){
                $ajax.sent({
                    method:'GET',
                    url:'/api/customer/getlistMock',
                    params:params
                }).then(function(res){
                    resolve(select2Config( arr.concat(res.data||[]), !nosearch ))
                }, reject);
            });
        };
    </script>
    <script type="text/xian" ui-bs>
        $API.Drop.Customer('all.search')
        .then(function(data){
            $timeout(function(){
                $scope.data = data
            }, 0) }
        );
    </script>
</div>
